var t = require("../@babel/runtime/helpers/typeof"),
  e = getApp();
function a(t) {
  return (
    "" == t ||
    "{}" == JSON.stringify(t) ||
    "NAN" == t ||
    0 == t ||
    null == t ||
    "null" == t ||
    null == t ||
    "undefined" === t ||
    "undefined" == t
  );
}
function n(t, e) {
  if (a(e)) return "";
  for (var n = e.length, r = [], i = 0; i < n; i++) e[i].f == t && r.push(e[i]);
  return r;
}
function r(t, e) {
  if ("string" == typeof t || "number" == typeof t)
    for (var a in e) if (e[a] == t) return !0;
  return !1;
}
function i(t, e) {
  if (a(e)) return "";
  for (var n = 0; n < e.length; n++) if (e[n].i == t) return e[n].v;
}
module.exports = {
  set_tabbar: function () {
    wx.setTabBarStyle({ selectedColor: e._ZEAI.color, borderStyle: "white" });
    var t = e._ZEAI.tabbar.length;
    if (t > 0)
      for (var a = 0; a < t; a++)
        wx.setTabBarItem({
          index: a,
          text: e._ZEAI.tabbar[a].text,
          iconPath: e._ZEAI.tabbar[a].iconPath,
          selectedIconPath: e._ZEAI.tabbar[a].selectedIconPath,
        });
  },
  c16_rgb: function (t) {
    if ("" == t) return "";
    t = (t = t.substring(1)).toLowerCase();
    var e,
      a = new Array();
    for (e = 0; e < 3; e++)
      (a[0] = t.substr(2 * e, 2)),
        (a[3] = "0123456789abcdef"),
        (a[1] = a[0].substr(0, 1)),
        (a[2] = a[0].substr(1, 1)),
        (a[20 + e] = 16 * a[3].indexOf(a[1]) + a[3].indexOf(a[2]));
    return a[20] + "," + a[21] + "," + a[22];
  },
  empty: a,
  ifmob: function (t) {
    return !!/^1[3,4,5,6,7,8,9]\d{9}$/.test(t);
  },
  ifsfz: function (t) {
    return !1 !== /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(t);
  },
  copy_text: function (t) {
    var e = a(t.msg) ? "复制成功" : t.msg;
    wx.setClipboardData({
      data: t.data,
      success: function (t) {
        wx.showToast({ title: e, icon: "success", duration: 2e3 });
      },
    });
  },
  o: function (t, e) {
    var a = wx.createSelectorQuery();
    a.select(t).boundingClientRect(),
      a.exec(function (t) {
        e(t);
      });
  },
  ifint: function (t) {
    return !!/^[0-9]*[1-9][0-9]*$/.test(t);
  },
  jsoneval: function (e) {
    return "object" != t(e)
      ? ((e = e.replace(/\ufeff/g, "")), JSON.parse(e))
      : e;
  },
  json_arr: function (t) {
    var e = [];
    for (var a in t) {
      var n = {};
      (n[a] = t[a]), e.push(n);
    }
    return e;
  },
  areaNEW: n,
  areaGetTtitle: function (t, e) {
    var r = t.length,
      i = e.ARR1,
      o = e.ARR2,
      s = e.ARR3,
      c = e.ARR4,
      u = [],
      l = [],
      f = [];
    if (r >= 1)
      var d = i[t[0]].i,
        v = i[t[0]].v;
    if (r >= 2) {
      var _ = n(d, o);
      if (!a(_))
        var p = _[t[1]].i,
          b = _[t[1]].v;
    }
    if (r >= 3) {
      var h = n(p, s);
      if (!a(h))
        var g = h[t[2]].i,
          m = h[t[2]].v;
    }
    if (r >= 4) {
      var k = n(g, c);
      if (!a(k))
        var x = k[t[3]].i,
          w = k[t[3]].v;
    }
    a(d) || (u.push(d), l.push(v));
    a(p) || (u.push(p), l.push(b));
    a(g) || (u.push(g), l.push(m));
    a(x) || (u.push(x), l.push(w));
    return (u = u.join(",")), (l = l.join(" ")), f.push(u), f.push(l), f;
  },
  in_array: r,
  set_checked: function (e, a) {
    for (var n = "object" == t(e) ? e : e.split(","), i = 0; i < a.length; i++)
      r(a[i].i, n) ? (a[i].ed = !0) : (a[i].ed = !1);
    return a;
  },
  checkbox_div_list_get_listTitle: function (e, n) {
    if (a(e) || a(n)) return "";
    for (
      var r = "object" != t(e) ? e.split(",") : e, o = [], s = 0;
      s < r.length;
      s++
    )
      o.push(i(r[s], n));
    return o.join(",");
  },
  idx_iv: function (e, n) {
    if (a(e) || a(n)) return "";
    var r,
      i = "object" != t(e) ? e.split(",") : e,
      o = i.length,
      s = (n.length, []),
      c = [],
      u = [];
    if (o > 1) {
      for (var l = 0; l < o; l++) (r = i[l]), s.push(n[r].i), c.push(n[r].v);
      u.push(s.join(","), c.join("～"));
    } else u.push(n[e].i, n[e].v);
    return u;
  },
  sorry: function (t) {
    var e = t.this;
    switch (t.flag) {
      case "noreg":
        wx.navigateTo({
          url: "/pages/login/login?tguid=" + t.tguid + "&admid=" + t.admid,
        });
        break;
      case "tg_noreg":
        wx.redirectTo({
          url: "/pages/tg/login?tguid=" + t.tguid + "&admid=" + t.admid,
        });
        break;
      case "nosign":
        wx.showModal({
          content: t.title,
          confirmColor: e.data.color,
          confirmText: "朕知道了",
          showCancel: !1,
          success: function (t) {
            wx.navigateBack();
          },
        });
        break;
      case "nodata":
        e.setData({
          div_data: !0,
          div_data_title: t.title,
          mask_class: "alpha0_100",
        });
        break;
      case "nocontact":
        break;
      case "nogps":
        e.setData({
          div_gps: !0,
          div_gps_title: t.title,
          mask_class: "alpha0_100",
        });
        break;
      case "nolevel":
        e.setData({
          div_vip: !0,
          div_vip_title: t.title,
          div_vip_content: t.content,
          div_vip_H: t.H,
          mask_class: "alpha0_100",
        });
        break;
      case "nocert":
        e.setData({
          div_cert: !0,
          div_cert_title: t.title,
          mask_class: "alpha0_100",
        });
        break;
      case "nophoto":
        e.setData({
          div_data: !0,
          div_data_title: t.title,
          mask_class: "alpha0_100",
        });
        break;
      case "clickloveb_confirm":
        e.setData({
          div_clickloveb_confirm: !0,
          div_data_title: t.title,
          mask_class: "alpha0_100",
        });
        break;
      case "noloveb":
        e.setData({
          div_noloveb: !0,
          div_data_title: t.title,
          mask_class: "alpha0_100",
        });
        break;
      case "noucount":
        e.setData({
          div_noucount: !0,
          div_data_title: t.title,
          mask_class: "alpha0_100",
        });
        break;
      default:
        wx.showModal({
          content: t.msg,
          confirmColor: e.data.color,
          confirmText: "朕知道了",
          showCancel: !1,
          success: function (e) {
            "no" == t.url || wx.navigateBack();
          },
        });
    }
  },
  get_F_idx: function (t, e) {
    if (a(t) || a(e)) return 0;
    var n = e.length;
    if (n > 0) for (var r = 0; r < n; r++) if (e[r].fieldname == t) return r;
  },
  escape2Html: function (t) {
    var e = { lt: "<", gt: ">", nbsp: " ", amp: "&", quot: '"' };
    return (t = (t = t
      .replace(/&(lt|gt|nbsp|amp|quot);/gi, function (t, a) {
        return e[a];
      })
      .replace("<section", "<div")).replace(
      /<img/gi,
      '<img style="width:100%;height:auto;display:block" '
    ));
  },
  jsonurl: function (t) {
    return Object.keys(t)
      .map(function (e) {
        return encodeURIComponent(e) + "=" + encodeURIComponent(t[e]);
      })
      .join("&");
  },
  json_remove: function (e, a) {
    "object" != t(e) && (e = (e = e.toString()).split(","));
    var n = Array();
    for (var r in e) e[r] != a && n.push(e[r]);
    return n;
  },
  indexOf: function (e, a) {
    (e = e.toString()),
      (a = a.toString()),
      "object" != t(e) && (e = e.split(","));
    return !(e.indexOf(a) < 0);
  },
  get_tabbar_index: function (t) {
    var a = e._ZEAI.tabbar.length,
      n = 3;
    if (a > 0)
      for (var r = 0; r < a; r++) e._ZEAI.tabbar[r].var == t && (n = r);
    return n;
  },
};
